package com.seecen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seecen.common.BaseResponse;
import com.seecen.common.ResultUtils;
import com.seecen.mapper.ServiceMapper;
import com.seecen.pojo.entity.Category;
import com.seecen.pojo.vo.CategoryServVo;
import com.seecen.service.CategoryService;
import com.seecen.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 小辛
* @description 针对表【allmaster_category(分类表)】的数据库操作Service实现
* @createDate 2025-10-17 22:45:50
*/
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>
    implements CategoryService{
    @Autowired
    private CategoryMapper categoryMapper;

    @Autowired
    private ServiceMapper serviceMapper;

    @Override
    public BaseResponse<List> findBigType() {
        LambdaQueryWrapper<Category> wrapper = new LambdaQueryWrapper<>();
        wrapper.isNull(Category::getCategorytype);
        List<Category> categories = categoryMapper.selectList(wrapper);
        return ResultUtils.success(categories);
    }

    @Override
    public BaseResponse<List> findSmallType() {
        LambdaQueryWrapper<Category> wrapper = new LambdaQueryWrapper<>();
        wrapper.isNotNull(Category::getCategorytype);
        List<Category> categories = categoryMapper.selectList(wrapper);
        return ResultUtils.success(categories);
    }

    @Override
    public BaseResponse<List> findService() {
        List<CategoryServVo> categoryServVos = serviceMapper.selectCategoryIdAndServiceName();
        return ResultUtils.success(categoryServVos);
    }

    @Override
    public BaseResponse<List<Category>> getIndexCategory() {
        List<Category> categoryList = categoryMapper.selectList(null);
        if (categoryList != null && !categoryList.isEmpty()) {
            return ResultUtils.success(categoryList);
        }
        return null;
    }
}




